class MinStack {
    private stack: number[];
    private minstack: number[];



    constructor() {
        this.stack = [];
        this.minstack = [];
    }

    push(x: number): void {
        this.stack.push(x);
        if (this.minstack.length <= 0 || x <= this.minstack[this.minstack.length-1]) {
            this.minstack.push(x);
        }
    }

    pop(): void {
        let key  = this.stack.pop();
        if(this.minstack[this.minstack.length - 1] === key){
            this.minstack.pop();
        }
    }

    top(): number {
        console.log(this.stack);

        return this.stack[this.stack.length - 1];

    }

    min(): number {
        console.log(this.minstack);

        return this.minstack[this.minstack.length - 1];
    }
}

// var obj:MinStack= new MinStack()
// obj.push(1)
// obj.push(3)
// obj.push(2)
// obj.push(4)

// obj.pop()
// var param_3 = obj.top()
// var param_4 = obj.min()


// console.log(param_3);
// console.log(param_4);

/**
 * Your MinStack object will be instantiated and called as such:
 * var obj = new MinStack()
 * obj.push(x)
 * obj.pop()
 * var param_3 = obj.top()
 * var param_4 = obj.min()
 */